<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %>

<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<h4>组织机构<a href="${ctx }/admin/office/form" class="btn-link btn-sm "><span
        class="glyphicon glyphicon-plus-sign"></span>新组织机构</a></h4>

<form class="form-inline well" role="form" id="search-form">
    <input type="hidden" name="s" value="20">

    <div class="form-group">
        <label for="delFlag">状态 :</label>
        <select class="form-control input-sm selectpicker" data-width="100px" data-style="btn-sm" data-size=10
                id="delFlag" name="delFlag">
            <option value="">全部</option>
            <c:forEach items="${fns:getDictList('del_flag_type')}" var="dict">
                <option value="${dict.value }">${dict.label }</option>
            </c:forEach>
        </select>

    </div>
    <div class="form-group">
        <label for="email">邮件地址:</label>
        <input class="form-control input-sm" id="email" name="email" size="30" type="text">
    </div>
    <button type="button" class="btn btn-primary btn-sm btn-search-submit">确认</button>
    <a href="${ctx }/admin/user/manage" class="btn btn-default btn-sm">刷新</a>
</form>
<div id="list-data"></div>

<script id="list-template" type="text/html">
    <table id="user-table" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th style="width:3%;"><input type="checkbox" name="post[]" value="24"></th>
            <th>名称</th>
            <th>类型</th>
            <th>等级</th>
            <th>负责人</th>
            <th>电话</th>
            <th>联系地址</th>
            <th width="10%;">状态</th>
            <th width="10%;">操作</th>
        </tr>
        </thead>
        <tbody>
        {{each result as value i}}
        <tr>
            <td><input type="checkbox" name="post[]" value="24"></td>
            <td><span style="margin-left: {{value.grade*10}}px;">{{value.name }}</span></td>
            <td>
                <c:forEach items="${fns:getDictList('office_type')}" var="dict">
                    {{ if value.type == ${dict.value} }}${dict.label}{{/if}}
                </c:forEach>
            </td>
            <td>
                <c:forEach items="${fns:getDictList('office_grade')}" var="dict">
                    {{ if value.grade == ${dict.value} }}${dict.label}{{/if}}
                </c:forEach>
            </td>
            <td>
                {{if value.master != null}}{{value.master.name}}{{/if}}
            </td>
            <td>{{value.phone}}</td>
            <td>{{value.address}}</td>
            <td>
                {{ if value.delFlag == 0 }}<label class="label label-info">正常</label>{{/if}}
                {{ if value.delFlag == 1 }}<label class="label label-default">失效</label>{{/if}}
                {{ if value.delFlag == 2 }}<label class="label label-warning">锁定</label>{{/if}}
            </td>
            <td>
                {{ if !result[i].admin }}
                <a class="btn-link" href="${ctx}/admin/office/form?id={{ value.id }}"><span
                        class="glyphicon glyphicon-edit"></span>编辑</a>
                <a type="button" class="btn-link user-del" data='{"id":"{{ value.id }}"}'><span
                        class="glyphicon glyphicon-trash"></span>删除</a>
                {{/if}}
            </td>
        </tr>
        {{/each}}
        </tbody>
    </table>
    <div>
        {{#pagination }}
    </div>
</script>


<script type="text/javascript">
    <c:if test="${env == 'pro' }">
    requirejs(['${ctx}/assets/js/app/admin/office-manage-page.js']);
    </c:if>
    <c:if test="${env != 'pro' }">
    requirejs(['${ctx}/assets/js/app/admin/office-manage-page.js']);
    </c:if>
</script>
